Crate themelio_stf[][src]

Expand description

This crate contains the data structures and core algorithms that comprise Themelio’s core state machine. Any piece of software needing to parse Themelio data, validate Themelio transactions, or answer questions like “what happens to the Themelio state if transactions A, B, and C happen” can use this minimal-depedency crate.

Roughly, the structs in this crate are organized as follows:

  • State represents a full Themelio world-state and it’s not directly serializable. It includes all the information needed to validate new transactions and blocks, such as a SMT of all outstanding coins, Melmint parameters, etc. It has methods taking Transactions etc that advance the state, as well as others to produce serializable blocks, headers, etc.
  • Transaction represents a serializable Themelio transaction. It has some helper methods to count coins, estimate fees, etc, largely to help build wallets.
  • StakeDoc, which every State includes, encapsulates the Symphonia epoch-based stake information.
  • SmtMapping represents a type-safe SMT-backed mapping that is extensively used within the crate.

Modules

melpow is the crate that implements MelPoW, Themelio’s version of non-interactive proofs of sequential work, which are just “Interactive Proofs of Sequential Work” by Cohen and Pietrzak subjected to a Fiat-Shamir transformation. MelPoW is used as the core mechanism behind Melmint, the algorithmic monetary policy system that stabilizes the mel.

Structs

An abbreviated block

A (serialized) block.

The data bound to a coin ID. Contains the “contents” of a coin, i.e. its constraint hash, value, and coin type.

A CoinData but coupled with a block height. This is what actually gets stored in the global state, allowing constraints and the validity-checking algorithm to easily access the age of a coin.

A coin ID, consisting of a transaction hash and index. Uniquely identifies a coin in Themelio’s history.

ConfirmedState represents a fully confirmed state with a consensus proof.

Configuration of a genesis state. Serializable via serde.

A block header, which commits to a particular SealedState.

A type that wraps a bytevector, serializing as hexadecimal for JSON.

A key identifying a pool.

ProposerAction describes the standard action that the proposer takes when proposing a block.

SealedState represents an immutable state at a finalized block height. It cannot be constructed except through sealing a State or restoring from persistent storage.

SmtMapping is a type-safe, constant-time cloneable, imperative-style interface to a sparse Merkle tree.

StakeDoc is a stake document. It encapsulates all the information needed to verify consensus proofs.

World state of the Themelio blockchain

Transaction represents an individual, serializable Themelio transaction.

A newtype representing the hash of a transaction.

Enums

Identifies a network.

A error that happens while applying a transaction to a state

An enumeration of all the different possible transaction kinds. Currently contains a “faucet” kind that will be (obviously) removed in production.

Constants

Maximum coin value

1e6

A stake epoch is 200,000 blocks.

TIP 901: change fee multiplier calculation

TIP 902: introduce non-MEL/non-MEL pools

Functions

Reward calculator. Returns the value in real DOSC.

DOSC inflation calculator.

DOSC inflation ratio.

Presealing function that is called before a state is sealed to apply melmint actions.

Type Definitions